﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace TestWeb.Controllers
{
    public class BaseController : Controller
    {
        protected void WxLogin()
        {
            if (Session["token"] == null && Session["openid"] == null)
            {
                if (Request.Params["code"] != null)
                {
                    Wx.Model.Token.WebAccessToken webToken = Wx.Api.Token.Web_GetToken(Request.Params["code"]);
                    if (webToken != null)
                    {
                        Session["token"] = webToken.access_token;
                        Session["openid"] = webToken.openid;
                    }
                }
                else
                {
                    Response.Redirect("/Token?pre=" + Request.RawUrl);
                }
            }
        }
    }
}